/*
 * Author: Honrun
 */
#ifndef DEVICESIIC_H_
#define DEVICESIIC_H_




#define I2C1_SLAVE_ADDRESS7      0x01
#define I2C1_SPEED               400000

#define I2C2_SLAVE_ADDRESS7      0x02
#define I2C2_SPEED               400000

#define I2C3_SLAVE_ADDRESS7      0x03
#define I2C3_SPEED               400000



/* I2C handler declaration */
extern I2C_HandleTypeDef ex_IIC1Handle;
extern I2C_HandleTypeDef ex_IIC2Handle;
extern I2C_HandleTypeDef ex_IIC3Handle;



void vIIC1Init(void);
void vIIC2Init(void);
void vIIC3Init(void);

void vIIC1DeInit(void);
void vIIC2DeInit(void);
void vIIC3DeInit(void);



int8_t cIICWriteDatas(I2C_HandleTypeDef *hi2c, uint16_t usIDAddr, uint16_t usRegAddr, uint8_t* pBuffer, int32_t iLength);
int8_t cIICWriteByte(I2C_HandleTypeDef *hi2c, uint16_t usIDAddr, uint16_t usRegAddr, uint8_t ucByte);
int8_t cIICReadDatas(I2C_HandleTypeDef *hi2c, uint16_t usIDAddr, uint16_t usRegAddr, uint8_t* pBuffer, int32_t iLength);
int8_t cIICReadByte(I2C_HandleTypeDef *hi2c, uint16_t usIDAddr, uint16_t usRegAddr, uint8_t *pucByte);

#define cIIC1WriteDatas(usIDAddr, usRegAddr, pBuffer, iLength)  cIICWriteDatas(&ex_IIC1Handle, (usIDAddr), (usRegAddr), (pBuffer), (iLength))
#define cIIC1WriteByte(usIDAddr, usRegAddr, ucByte)             cIICWriteByte(&ex_IIC1Handle, (usIDAddr), (usRegAddr), (ucByte))
#define cIIC1ReadDatas(usIDAddr, usRegAddr, pBuffer, iLength)   cIICReadDatas(&ex_IIC1Handle, (usIDAddr), (usRegAddr), (pBuffer), (iLength))
#define cIIC1ReadByte(usIDAddr, usRegAddr, pucByte)             cIICReadByte(&ex_IIC1Handle, (usIDAddr), (usRegAddr), (pucByte))

#define cIIC2WriteDatas(usIDAddr, usRegAddr, pBuffer, iLength)  cIICWriteDatas(&ex_IIC2Handle, (usIDAddr), (usRegAddr), (pBuffer), (iLength))
#define cIIC2WriteByte(usIDAddr, usRegAddr, ucByte)             cIICWriteByte(&ex_IIC2Handle, (usIDAddr), (usRegAddr), (ucByte))
#define cIIC2ReadDatas(usIDAddr, usRegAddr, pBuffer, iLength)   cIICReadDatas(&ex_IIC2Handle, (usIDAddr), (usRegAddr), (pBuffer), (iLength))
#define cIIC2ReadByte(usIDAddr, usRegAddr, pucByte)             cIICReadByte(&ex_IIC2Handle, (usIDAddr), (usRegAddr), (pucByte))

#define cIIC3WriteDatas(usIDAddr, usRegAddr, pBuffer, iLength)  cIICWriteDatas(&ex_IIC3Handle, (usIDAddr), (usRegAddr), (pBuffer), (iLength))
#define cIIC3WriteByte(usIDAddr, usRegAddr, ucByte)             cIICWriteByte(&ex_IIC3Handle, (usIDAddr), (usRegAddr), (ucByte))
#define cIIC3ReadDatas(usIDAddr, usRegAddr, pBuffer, iLength)   cIICReadDatas(&ex_IIC3Handle, (usIDAddr), (usRegAddr), (pBuffer), (iLength))
#define cIIC3ReadByte(usIDAddr, usRegAddr, pucByte)             cIICReadByte(&ex_IIC3Handle, (usIDAddr), (usRegAddr), (pucByte))

#endif /* DEVICESIIC_H_ */
